export default {
    namespaced: true,
    state: {
        name: "默认值"
    },
    mutations: {
        loadChangeName(state, newValue) {
            console.log("mutations_load", state, newValue);
            // console.log(a, b, c);
            state.name = "重新赋值_" + newValue
        },
        /**
         *
         * @param state 当前模块的 state
         * @param other
         *      this.$store.commit("test/changeName", {a:1,b:2}) 提交时值为{a:1,b:2}
         *      解构点击时是鼠标事件
         */
        changeName(state, other) {
            console.log("mutations", state, other);
            state.name = state.name + "_修改数据"
        }
    },
    getters: {
        /**
         *
         * @param state  当前模块的 state
         * @param getters 当前模块的 getters
         * @param $rootState 所有 state
         * @param $rootGetters 所有的 getters
         */
        computeName(state, getters, $rootState, $rootGetters) {
            console.log("getters", state, getters, $rootState, $rootGetters);
            return state.name + "_" + "计算"
        }
    },
    actions: {
        loadName($store) {
            console.log("actions", $store);
            setTimeout(() => {
                $store.commit("loadChangeName", "加载的数据")
            }, 1000)
        }
    },
    modules: {}
}
